package com.linkage.seapeak.activity.register;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.linkage.jz.bankruptcy.R;
import com.linkage.seapeak.base.BaseWhiteActivity;
import com.linkage.seapeak.pojo.QQAuthData;
import com.linkage.seapeak.pojo.WxAuthData;

import java.io.Serializable;

public class BindAccountActivity extends BaseWhiteActivity {

    Serializable data;

    TextView nameView;
    ImageView avatarView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bind_account, "关联登录账号");
        data = getIntent().getSerializableExtra("data");
        init();
    }

    private void init(){
        nameView = findViewById(R.id.name_view);
        avatarView = findViewById(R.id.avatar_view);
        findViewById(R.id.btn_next).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(BindAccountActivity.this, BindPhoneActivity.class);
                intent.putExtra("data", data);
                startActivity(intent);
                finish();
            }
        });

        if(data instanceof QQAuthData) {
            nameView.setText("亲爱的QQ用户：" + ((QQAuthData) data).getNickname()
                    + "\n\n为了给您更好的服务，请关联一个破晓账号");
            Glide.with(this).load(((QQAuthData) data).getIcon())
                    .placeholder(R.drawable.logo)
                    .into(avatarView);
        } else if(data instanceof WxAuthData) {
            nameView.setText("亲爱的微信用户：" + ((WxAuthData)data).getNickname()
                    + "\n\n为了给您更好的服务，请关联一个破晓账号");
            Glide.with(this).load(((WxAuthData) data).getIcon())
                    .placeholder(R.drawable.logo)
                    .into(avatarView);
        }
    }
}
